package com.hantanger.weblog.controller;

import java.io.IOException;
import java.io.OutputStream;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.hantanger.weblog.util.Cache;

/**
 * 文件内容显示
 * 
 * @author lys
 * 
 */
public class FileController extends BaseController {

	@Override
	public String doGet(HttpServletRequest request,
			HttpServletResponse response) {
		String fileName = request.getParameter("filename");
		String key = "filename_" + fileName;
		byte[] content = (byte[]) Cache.get(key);
		if (content != null) {
			try {
				OutputStream outputStream = response.getOutputStream();
				outputStream.write(content);
				outputStream.flush();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return null;
	}

}
